package org.example.struct.array2;

/**
 * @author liyishan
 * @date 2023/10/16 09:26
 * @apiNote
 */

public class Test00713NumSubarrayProductLessThanK {

    public static void main(String[] args) {
        int[] nums = {10,5,2,6};
        int k = 100;
        int count = test(nums,k);
        System.out.println(count);
    }

    public static int test(int[] nums, int k) {
        int n = nums.length, ret = 0;
        int prod = 1, i = 0;
        for (int j = 0; j < n; j++) {
            prod *= nums[j];
            while (i <= j && prod >= k) {
                prod /= nums[i];
                i++;
            }
            ret += j - i + 1;
        }
        return ret;
    }


}
